//
//  LPUtils.swift
//  LPAPP
//
//  Created by lipeng on 2021/3/17.
//

import UIKit


extension UIWindow {
    static var safeAreaTop: CGFloat = 0
    static var totalHeight: CGFloat = 20 + 44
    
    func setSafeAreaTop(_ top: CGFloat) {
        UIWindow.safeAreaTop = top
        UIWindow.totalHeight = top + 44
    }
}


public class LPUtils {
    /// 设置Window
    @available(iOS 13.0, *)
    public class func addWindowWithVC(_ vc: UIViewController, _ scene: UIScene) -> UIWindow {
        if let windowScene = (scene as? UIWindowScene){
            let window = UIWindow.init(frame: UIScreen.main.bounds)
            window.windowScene = windowScene
            window.backgroundColor = UIColor.white
            window.rootViewController = vc
            window.makeKeyAndVisible()
            return window
        } else {
            let window = UIWindow.init(frame: UIScreen.main.bounds)
            window.backgroundColor = UIColor.white
            window.rootViewController = vc
            window.makeKeyAndVisible()
            return window
        }
    }
    
    public class func addWindowWithVCSub(_ vc: UIViewController) -> UIWindow {
        let window = UIWindow.init(frame: UIScreen.main.bounds)
        window.backgroundColor = UIColor.white
        window.rootViewController = vc
        window.makeKeyAndVisible()
        return window
    }
}
